﻿using Newtonsoft.Json.Linq;
using SuperX.Common.Log;
using SuperX.SuperSocket.Server;
using SuperSocket.SocketBase.Command;
using System;
using System.Collections.Generic;
using System.Text;
using SuperX.SuperSocket.Socket.Server;
using SuperX.SuperSocket.Socket.Message;

namespace SuperX.SuperSocket.Socket.Command
{
    public class KeyValuePairsCommand : CommandBase<Session, MessageRequestInfo>
    {
        public override string Name => "SendObjectWithHeaders";

        public override void ExecuteCommand(Session session, MessageRequestInfo requestInfo)
        {
            try
            {
                var socketMessage = requestInfo.Body;
                socketMessage.Headers = CommandTransfer.ConvertHeaders(socketMessage.Header);
                socketMessage.Header = string.Empty;
                CommandTransfer.FireMessageReceived(session, new MessageEventArgs(session, socketMessage));
            }
            catch (Exception e)
            {
                Logger.Error(e.Message);
            }
        }
    }
}